package com.taiyuan.zfmvp.JUC.list;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @param
 * @Author: zhoufang@si-tech.com.cn
 * @Descriiption: list集合 线程不安全
 * @Date 2022/10/4
 * @return
 */
public class ThreadDemo4 {

    public static void main(String[] args) {

        List<String> list = new CopyOnWriteArrayList<>();
        for (int i = 0; i < 30; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    list.add(UUID.randomUUID().toString());
                    System.out.println(list);
                }
            }).start();
        }
    }
}
